package test;

import lombok.extern.slf4j.Slf4j;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Description TODO
 * @Author lxp
 * @Date 2022/9/29 下午3:46
 * @Version V1.0
 **/
@Slf4j
public class test2 {
    public static void main(String[] args) {

//        String inPaht ="/Users/lxp/IdeaProjects/Study/MainTest/data/test";
//        String outPaht ="/Users/lxp/IdeaProjects/Study/MainTest/data/newTest";
//        List<File> files = FileUtil.loopFiles(Paths.get(inPaht), 3, null);
//        for (File file : files) {
//            String absolutePath = file.getAbsolutePath();
//            String fileName = file.getName();
//            String tmpPath = absolutePath.substring(absolutePath.indexOf(inPaht), absolutePath.lastIndexOf(fileName));
//            String newFile  = outPaht+File.separator+tmpPath+File.separator+fileName;
//            System.out.println(newFile);
//        }
        String path = "/Users/lxp/IdeaProjects/Study/MainTest/data/test/ff/ff2/tt.txt";
        String inPath = "/Users/lxp/IdeaProjects/Study/MainTest/data/test";
        String substring = path.substring(0, path.lastIndexOf("tt.txt"));
        String substring2 = substring.substring(inPath.length());
        System.out.println(substring);
        System.out.println(substring2);
    }

    public static String convertFormat(String input, String fromFormat, String toFormat) {
        SimpleDateFormat formatter = new SimpleDateFormat(fromFormat);
        Date date = null;
        try {
            date = formatter.parse(input);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
        formatter = new SimpleDateFormat(toFormat);
        return formatter.format(date);
    }
}



